<template>
<view class="content" @touchmove.stop.prevent="() => {}">
	<div class="my_work_box" id="myworkbox">
		<div class="titlebox">
			<image src="/static/arrow-left.png" style="height: 23px;width: 23px;margin-right: 12px;" @click="toback()"></image>
			<text style="color: black;font-size: 20px;font-weight:bold">资料目录</text>	
		</div>
		<scroll-view scroll-y="true" show-scrollbar="false" class="public_box">
			<div class="studyList" v-for="item in studyList" @click="todownload(item.subject)">
				<div style="display: flex; align-items: center;">
					<image src="/static/folder.png" style="width: 50px;height: 50px;margin-left: 10px;"></image>
					<div style="display: flex;flex-direction: column;border-radius: 16px 0 0 16px;">
						<text style="margin: 0 0 0 10px;font-size: 18px;font-weight: bold;">{{item.subject}}</text>
						<text style="margin: 10px 0 0 10px;color: gray;">共{{item.cnt}}份资料</text>
					</div>
				</div>
				<image src="/static/arrow-right.png" style="width: 23px;height: 23px;margin-right: 13px;"></image>
			</div>
		</scroll-view>
	</div>
</view>
</template>

<script>
	export default {
		onShareAppMessage(){},
		onShareTimeline(){},
		created() {
			this.getstudyList();
		},
		data() {
			return {
				studyList:[],
			}
		},
		methods: {
			getstudyList(){
				uni.request({
					url: 'https://127.0.0.1/data/getstudyList.php',
					method: 'POST',
					header: {
						'content-type': 'application/json',
					},
					success: (res) => {
						this.studyList=res.data;
					}
				})
			},
			toback(){
				if (getCurrentPages().length > 1) {
					uni.navigateBack({ delta: 1 }); 
				} else {
					uni.redirectTo({
						url: '/pages/index/home'
					});
				}
			},
			todownload(title){
				uni.navigateTo({
					url: '/pages/document/download_layout?title='+title
				})
			},
		}
	}
</script>

<style>
.content {
		margin-top: 11%;
		width: 100%;
		height: 100%;
		display: flex;
		flex-direction: column;
		align-items: left;
		justify-content: center;
	}
	.titlebox {
		top: 0;
		display: flex;
		flex-direction: row;
		align-items: center;
		margin-left: 15px;
		margin-bottom: 20px;
		letter-spacing: 1px;
	}
	.my_work_box {
		margin: 10px 5px;
		display: flex;
		flex-direction: column;
		align-items: left;
		justify-content: center;
	}
	.public_box{
		height: calc(100vh - 130px);
		width: 100%;
		display: flex;
		flex-direction: column;
		justify-content: space-around;
		box-sizing: border-box;
		align-items: center;
	}
	.studyList{
		margin-bottom: 15px;
		display: flex;
		flex-direction: row;
		width: 95%;
		height: 80px;
		background-color: white;
		margin-left: 2.5%;
		border-radius: 16px;
		justify-content: space-between;
		align-items: center;
	}
</style>
